package w3


class Xs {
  private var _name: String = null
  private var _age: Int = 0
  private var _sex: Char = '男'

  def name = _name
  //getName

  def name_(n: String): Unit = {
    TestSTudent.show()
    _name = n
  } //setName

  def age =
    _age


  def age_(a: Int): Unit = {
    if (a < 14 || a > 60) {
      println(s"年龄${a}不合理")
    } else {
      _age = a
    }
  }

  def sex = {
    _sex
  }

  def sex(c: Char): Unit = {
    if (c == '男' || c == '女')
      _sex = c
    else
      println("性别不合理")
  }

  override def toString: String = {
    _name + "," + _age + "," + _sex
  }

  class Subject(val name: String) {

  }
}

object TestSTudent {
  def main(args: Array[String]): Unit = {
    show()
    var s1 = new Xs()

    //var b = new s.Subject()
    //s1.name = "胡本爽"
    //s1.age = 22

    println(s1)
  }

  def show(): Unit = {
    println("这是一个学生的测试类")
  }
}
